package com.NeuglsWorkStudio.UI.FormElement.Component
{
	import com.NeuglsWorkStudio.Colors.ColorUtility;
	import com.NeuglsWorkStudio.Colors.HSL;
	import com.NeuglsWorkStudio.Colors.RGB;
	import com.NeuglsWorkStudio.UI.FormElement.Config.TConfig;
	import com.NeuglsWorkStudio.UI.FormElement.Config.TMemoConfig;
	
	import flash.geom.Rectangle;
	import flash.text.*;

	public class TMemo extends TCustomEdit
	{
		private var _FTextArea:TextField;
		private var _FTextFormat:TextFormat;
		
		public function TMemo(AConfig:TConfig)
		{
			super(AConfig);
		}
		
		override protected function Init():void{
			super.Init();
			_FTextArea=new TextField();
			_FTextFormat=new TextFormat("Tahoma",12,ColorUtility.GetColorFromBaseColor(BaseColor));
			_FTextFormat.leftMargin=5;
			_FTextFormat.rightMargin=5;
			_FTextArea.defaultTextFormat=_FTextFormat;

			
			_FTextArea.width=_FConfig.Width;
			_FTextArea.height=_FConfig.Height;
			_FTextArea.multiline=true;
			_FTextArea.wordWrap=true;
			_FTextArea.border=(_FConfig as TMemoConfig).HaveBorder;
			
			_FTextArea.borderColor=ColorUtility.GetBorderColorFromBaseColor(BaseColor);

			if((_FConfig as TMemoConfig).IsHTML){
				_FTextArea.htmlText=(_FConfig as TMemoConfig).Text;
			}else{
				_FTextArea.text=(_FConfig as TMemoConfig).Text;
			}
			
			if((_FConfig as TMemoConfig).Style){
				_FTextArea.styleSheet=(_FConfig as TMemoConfig).Style;
			}
			this.addChild(_FTextArea);
		}
		override protected function GetText():String{
			return (_FConfig as TMemoConfig).IsHTML?_FTextArea.htmlText:_FTextArea.text;
		}
		
		override protected function SetText(val:String):void{
			if((_FConfig as TMemoConfig).IsHTML){
				_FTextArea.htmlText=val;
			}else{
				_FTextArea.text=val;
			}
		}
	}
}